package cn.gemiman.daoyi.module.netty.server.processor;


import cn.gemiman.daoyi.module.netty.enums.NettyCmdType;
import cn.hutool.extra.spring.SpringUtil;

public class ProcessorFactory {

    public static AbstractMessageProcessor<?> createProcessor(NettyCmdType cmd) {
        AbstractMessageProcessor<?> processor = null;
        switch (cmd) {
            case LOGIN:
                processor = SpringUtil.getBean(LoginProcessor.class);
                break;
            case HEART_BEAT:
                processor = SpringUtil.getBean(HeartbeatProcessor.class);
                break;
            case PRIVATE_MESSAGE:
                processor = SpringUtil.getBean(PrivateMessageProcessor.class);
                break;
            case GROUP_MESSAGE:
                processor = SpringUtil.getBean(GroupMessageProcessor.class);
                break;
            default:
                break;
        }
        return processor;
    }

}
